#Makefile

include ../config.mak
include sub.mak

all: libhwicodec.a libicommon.a

#libicommon.a
ICOMMON_DIR = ../icommon

# libhwicodec.a
INCLUDES = ${INCLUDE_COMMON} -Iinclude -Isrc/protocol/include
INCLUDES += -I$(ICOMMON_DIR)/include
INCLUDES += -I ../../../include
INCLUDES += -I../../../../../include/api/cn
CFLAGS = ${CFLAGS_COMMON} $(INCLUDES)

OBJS = $(OBJS-$(HWICODEC))

$(OBJS):%.o:%.c
	$(CC) -c $(CFLAGS) -o $@ $<

libhwicodec.a: $(OBJS) libicommon.a
	$(LD) -EL $(LDFLAGS) -o $@ -r -static $(OBJS) $(ICOMMON_DIR)/libicommon.a

libicommon.a:
	$(MAKE) -C $(ICOMMON_DIR)

.PHONY: clean distclean
clean:
	$(MAKE) clean -C $(ICOMMON_DIR)
	-rm -f $(OBJS)

distclean: clean
	$(MAKE) distclean -C $(ICOMMON_DIR)
	-rm -f libhwicodec.a
